class Solution:
    def interchangeableRectangles(self, rectangles: list) -> int:
        res = 0
        counter = {}
        for rec in rectangles:
            ratios = rec[0] / rec[1]
            if ratios not in counter:
                counter[ratios] = 0
            res += counter[ratios]
            counter[ratios] += 1

        return res
